package com.hebeiboruan.aop;

import com.hebeiboruan.common.exception.CommonException;
import com.hebeiboruan.common.uitl.LoggerUtil;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.stereotype.Component;

@Aspect
@Component
@EnableAspectJAutoProxy
public class ExceptionAOP {
    @AfterThrowing(pointcut = "execution(* com.hebeiboruan.*.*.*.*(..))",throwing = "e")
    public void exception(Exception e){
    if(!(e instanceof CommonException)){
        LoggerUtil.error(e.getMessage());
    }
    }
}
